<template>
  <el-card shadow="never" class="aui-card--fill managementWrapper">
    <div class="mod-sys__user">
      <el-form
        :inline="true"
        :model="dataForm"
        @keyup.enter.native="getDataList()"
      >
        <el-form-item>
          <el-input v-model="dataForm.supplier_serial" placeholder="供应商编号"></el-input>
        </el-form-item>
        <el-form-item>
          <el-input v-model="dataForm.name" placeholder="供应商名称"></el-input>
        </el-form-item>
        <!-- <el-form-item>
                <ren-dept-tree v-model="dataForm.deptId" :placeholder="$t('dept.title')" :query="true"></ren-dept-tree>
              </el-form-item> -->
        <el-form-item>
          <el-button @click="handleSearch()">搜索</el-button>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" @click="toAdd()">创建供应商</el-button>
        </el-form-item>
      </el-form>
      <el-table
        v-loading="dataListLoading"
        :data="dataList"
        border
        @selection-change="dataListSelectionChangeHandle"
        @sort-change="dataListSortChangeHandle"
        style="width: 100%"
      >
        <el-table-column
          type="index"
          label="序号"
          header-align="center"
          align="center"
          width="80"
        ></el-table-column>
        <el-table-column
          prop="supplier_serial"
          label="供应商编号"
          header-align="center"
          align="center"
          width="241"
        ></el-table-column>
        <el-table-column
          prop="name"
          label="供应商名称"
          width="210"
          header-align="center"
          align="center"
        >
        </el-table-column>
        <el-table-column
          prop="legal_person"
          label="法人代表"
          header-align="center"
          align="center"
        >
        </el-table-column>
        <el-table-column
          prop="username"
          label="联系人"
          header-align="center"
          align="center"
        ></el-table-column>
        <el-table-column
          prop="phone"
          label="联系电话"
          header-align="center"
          align="center"
        ></el-table-column>
        <el-table-column
          prop="operator_user"
          label="最后操作人"
          header-align="center"
          align="center"
          width="100"
        ></el-table-column>
        <el-table-column
          prop="operator_time"
          label="最后操作时间"
          sortable="custom"
          header-align="center"
          align="center"
          width="180"
        ></el-table-column>
        <el-table-column
          :label="$t('handle')"
          fixed="right"
          header-align="center"
          align="center"
          width="150"
        >
          <template slot-scope="scope">
            <el-button type="text" size="small" @click="toAdd(scope.row)"
              >编辑</el-button
            >
            <el-button type="text" size="small" @click="toDetail(scope.row)"
              >详情</el-button
            >
            <el-button
              type="text"
              size="small"
              @click="deleteHandle(scope.row.id)"
              >删除</el-button
            >
          </template>
        </el-table-column>
      </el-table>
      <el-pagination
        :current-page="page"
        :page-sizes="[10, 20, 50, 100]"
        :page-size="num"
        :total="total"
        layout="total, sizes, prev, pager, next, jumper"
        @size-change="pageSizeChangeHandle"
        @current-change="pageCurrentChangeHandle"
      >
      </el-pagination>
      <el-dialog :visible.sync="dialogVisible" title="查看">
        <img width="100%" :src="dialogImageUrl" class="avatar" />
      </el-dialog>
    </div>
  </el-card>
</template>
  
  <script>
import mixinViewModule from "@/mixins/view-module";
import { addDynamicRoute } from "@/router";
export default {
  mixins: [mixinViewModule],
  data() {
    return {
      mixinViewModuleOptions: {
        getDataListURL: "/supplier",
        getDataListIsPage: true,
        deleteURL: "/supplier_delete",
        deleteIsBatch: true,
      },
      dataForm: {
        name: "",
        supplier_serial: "",
      },
    };
  },
  created() {
  },
  methods: {
    handleSearch() {
      this.getDataList();
    },
    toDetail(row) {
      const routeParams = {
        routeName: `${this.$route.name}__${row.id}`,
        title: `${this.$route.meta.title} - 详情`,
        path: "supply/management-detail",
        params: {
          id: row.id,
        },
      };
      addDynamicRoute(routeParams, this.$router);
    },
    toAdd(row) {
      const des = row ? "编辑" : "新增";
      const type = row ? "edit" : "add";
      const routeParams = {
        routeName: `${this.$route.name}__${type}`,
        title: `${this.$route.meta.title} - ${des}`,
        path: "supply/management-add",
        params: {
          id: row?.id || "",
        },
      };
      addDynamicRoute(routeParams, this.$router);
    },
  },
};
</script>
  
  